<template>
    <div>
        <a-input placeholder="用户名" style="width:50%;margin-top: 100px" v-model="username">
            <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)" />
        </a-input>
        <br>
        <br>
        <a-input placeholder="密码" style="width:50%" v-model="password">
            <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" />
        </a-input>
        <br>
        <a-button type="primary" @click="Login">
            登录
        </a-button>
    </div>
</template>

<script>
export default {
    name: "login",
    data(){
        return{
            username: '',
            password: ''
        }
    },
    methods:{
        Login(){
            this.$axios.post('login/',{
                'username': this.username,
                'password': this.password
            }).then(resp=>{
                alert(resp.data.msg)
                sessionStorage.setItem('token', resp.data.token)
                if(resp.data.code==200){
                    this.$router.push('/')
                }
            })
        }
    }
}
</script>

<style scoped>

</style>
